#include <iostream>
using namespace std;
const int N = 200005;
int n, ans, len;
int a[N];
int main(){
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 1; i < n; i += 2){
		if (a[i] < a[i - 1] + a[i + 1]){
			ans += a[i - 1];
			len += 2;
		}
		else {
			ans += a[i];
			i++;
			len += 3;
		}
	} 
	ans += a[len];
	cout << ans << endl;
	 
    return 0;
}


